package happy.diandiankong.api.db;

import happy.diandiankong.api.model.Groups;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;

/**
 * Title.
 * <p>
 * Description.
 *
 * @author Bill Lv {@literal <billcc.lv@hotmail.com>}
 * @version 1.0
 * @since 2016-10-30
 */
public interface GroupDao extends AutoCloseable, Transactional<GroupDao> {
    @SqlUpdate("INSERT INTO DDK_GROUPS (ID, NAME) VALUES (:ID, :NAME)")
    void insert(@Bind("ID") Long id, @Bind("NAME") String name);

    @SqlQuery("SELECT ID, NAME FROM DDK_GROUPS WHERE NAME = :NAME")
    @Mapper(GroupMapper.class)
    Groups findByName(@Bind("NAME") String name);
}
